package mars;

import mars.Position.Heading;

public class RotateCommand implements Command {
	
	private RotateAngle rotateAngle;
	@Override
	public Position process(Position currPosition) throws ParseException {
		Heading heading = currPosition.getHeading();
		int value = (heading.getHeadingAngle() + rotateAngle.getNumericRotate()) % 4;
		if(value == 0) {
			value = 4;
		}
		Heading newHeading = heading.getHeadingFromAngle(value);
		currPosition.setHeading(newHeading);
		return currPosition;
	}

	public void setRotateAngle(RotateAngle rotateAngle) {
		this.rotateAngle = rotateAngle;
	}
	
	public enum RotateAngle {
		L(-1), R(1);
		int numericRotate;
		
		RotateAngle(int numericRotate) {
			this.numericRotate = numericRotate;
		}
		
		public int getNumericRotate() {
			return numericRotate;
		}
	}; 
}

